Cypress automatically listens for pop-ups, alerts, and browser dialogs and lets you control or assert their behavior.
Handling window.alert(): Cypress automatically closes alerts, but you can assert their text using the cy.on() method.
Handling window.confirm() Cypress automatically clicks 'OK' by default, but you can: Assert the confirm message or Stub the return value to simulate clicking 'Cancel'
Handling window.prompt(): You can stub the prompt using cy.window() and cy.stub().
Custom HTML/CSS Popups (Modals, Toasts, Dialogs) If it’s not a browser alert/confirm/prompt and is instead a custom modal (e.g., Bootstrap, Material UI):